package kr.lgh.sms_creditcard.BankType;

import java.util.ArrayList;

import android.util.Log;

public class BankInfo {

	int s_id;
	String s_place;
	String s_date;
	int s_year;
	int s_month;
	String s_time;
	int s_money;
	String s_card;
	String s_category;
	int s_cardT_id;
	int s_categoryT_id;

	public BankInfo() {
		super();
	}

	// DGB카드
	public BankInfo divide_DGBbank(String msg, String formattedDate,
			String s_card, int s_cardT_id) {
		BankInfo daegu = new BankInfo();

		String[] arDivide = msg.split(" ");
		if (msg.contains("DGB") && arDivide[0].equals("DGB")) {
			String[] arTemp = msg.split("\n");
			String[] arDate = formattedDate.split("/");

			for (int i = 0; i < arTemp[0].split(" ").length; i++) {
				Log.d("TAG", "arTemp[0][" + i + "] : "
						+ arTemp[0].split(" ")[i]);
			}

			String s_time = arTemp[0].split(" ")[2];
			String s_date = formattedDate;
			int s_year = Integer.parseInt(arDate[0]); // 년도
			int s_month = Integer.parseInt(arDate[1]); // 월
			int s_money = Integer.parseInt(arTemp[2].substring(3).replace(",",
					""));
			String s_place;

			if (arTemp.length == 5) {
				Log.d("TAG", "현장 결제");
				s_place = arTemp[4];
			} else {
				Log.d("TAG", "일반 출금");
				s_place = "";
			}

			daegu.s_date = s_date;
			daegu.s_year = s_year;
			daegu.s_month = s_month;
			daegu.s_money = s_money;
			daegu.s_place = s_place;
			daegu.s_time = s_time;
			daegu.s_card = s_card;
			daegu.s_cardT_id = s_cardT_id;
			daegu.s_category = "없음";
			daegu.s_categoryT_id = 0;
		}

		return daegu;
	}

	// KB국민체크 카드
	public BankInfo divide_KBBank(String msg, String formattedDate,
			String s_card, int s_cardT_id) {

		BankInfo kb = new BankInfo();
		String[] arTemp = msg.split("\n");
		ArrayList<String> arSplit = new ArrayList<String>();
		String[] arDate = formattedDate.split("/");
		int s_year = 0, s_month = 0, end, s_money = 0;
		String s_date = "", s_time = "";

		s_year = Integer.parseInt(arDate[0]); // 년도
		s_month = Integer.parseInt(arDate[1]); // 월
		s_date = formattedDate; // 년도,월, 일
		// Log.d("TAG", "formattedDate : " + formattedDate);
		Log.d("TAG", "arDate : " + arDate[0] + ", " + arDate[1]);

		if (arTemp[0].equals("[Web발신]")) {
			for (int i = 1; i < arTemp.length; i++) {
				arSplit.add(arTemp[i]);
			}
			Log.d("TAG", "arSplit : " + arSplit.toString());
			s_time = arSplit.get(2).split(" ")[1];
			end = arSplit.get(3).toString().indexOf("원");
			s_money = Integer.parseInt(arSplit.get(3).toString()
					.substring(0, end).replace(",", ""));

			Log.d("TAG", "s_time : " + s_time);
			Log.d("TAG", "end : " + end);
			Log.d("TAG",
					"s_money : "
							+ arSplit.get(3).toString().substring(0, end)
									.toString());
			kb.s_place = arSplit.get(4);

			kb.s_date = s_date;
			kb.s_year = s_year;
			kb.s_month = s_month;
			kb.s_money = s_money;
			kb.s_time = s_time;
			kb.s_card = s_card;
			kb.s_cardT_id = s_cardT_id;
			kb.s_category = "없음";
			kb.s_categoryT_id = 0;

		} else if (arTemp.length == 5) {

			s_time = arTemp[2].split(" ")[1]; // 시간
			end = arTemp[3].indexOf("원");
			s_money = Integer.parseInt(arTemp[3].substring(0, end).replace(",",
					""));

			kb.s_place = arTemp[4];

			kb.s_date = s_date;
			kb.s_year = s_year;
			kb.s_month = s_month;
			kb.s_money = s_money;
			kb.s_time = s_time;
			kb.s_card = s_card;
			kb.s_cardT_id = s_cardT_id;
			kb.s_category = "없음";
			kb.s_categoryT_id = 0;

		}
		return kb;
	}

	// 대구BC체크 카드
	public BankInfo divide_DaeguBC(String msg, String formattedDate,
			String s_card, int s_cardT_id) {
		BankInfo daeguBC = new BankInfo();
		String[] arTemp = msg.split("\n");
		String[] arDate = formattedDate.split("/");

		if (arTemp.length == 6) {

			String s_time = arTemp[3].split(" ")[1];
			String s_date = formattedDate;
			int s_year = Integer.parseInt(arDate[0]); // 년도
			int s_month = Integer.parseInt(arDate[1]); // 월

			int end = arTemp[1].indexOf("원");
			int s_money = Integer.parseInt(arTemp[1].substring(0, end).replace(
					",", ""));
			String s_place = arTemp[5];

			daeguBC.s_date = s_date;
			daeguBC.s_year = s_year;
			daeguBC.s_month = s_month;
			daeguBC.s_money = s_money;
			daeguBC.s_place = s_place;
			daeguBC.s_time = s_time;
			daeguBC.s_card = s_card;
			daeguBC.s_cardT_id = s_cardT_id;
			daeguBC.s_category = "없음";
			daeguBC.s_categoryT_id = 0;

		}
		return daeguBC;
	}

	/*
	 * getter, setter
	 */
	public int getS_id() {
		return s_id;
	}

	public void setS_id(int s_id) {
		this.s_id = s_id;
	}

	public String getS_place() {
		return s_place;
	}

	public void setS_place(String s_place) {
		this.s_place = s_place;
	}

	public String getS_date() {
		return s_date;
	}

	public void setS_date(String s_date) {
		this.s_date = s_date;
	}

	public int getS_year() {
		return s_year;
	}

	public void setS_year(int s_year) {
		this.s_year = s_year;
	}

	public int getS_month() {
		return s_month;
	}

	public void setS_month(int s_month) {
		this.s_month = s_month;
	}

	public String getS_time() {
		return s_time;
	}

	public void setS_time(String s_time) {
		this.s_time = s_time;
	}

	public int getS_money() {
		return s_money;
	}

	public void setS_money(int s_money) {
		this.s_money = s_money;
	}

	public String getS_card() {
		return s_card;
	}

	public void setS_card(String s_card) {
		this.s_card = s_card;
	}

	public String getS_category() {
		return s_category;
	}

	public void setS_category(String s_category) {
		this.s_category = s_category;
	}

	public int getS_cardT_id() {
		return s_cardT_id;
	}

	public void setS_cardT_id(int s_cardT_id) {
		this.s_cardT_id = s_cardT_id;
	}

	public int getS_categoryT_id() {
		return s_categoryT_id;
	}

	public void setS_categoryT_id(int s_categoryT_id) {
		this.s_categoryT_id = s_categoryT_id;
	}

}
